package top.lixunda.ecommerce.server.auth.api.feign;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import top.lixunda.ecommerce.server.auth.api.entity.cache.CacheAuthCode;
import top.lixunda.ecommerce.server.auth.api.entity.dto.EmailGeneralCodeDTO;
import top.lixunda.ecommerce.server.auth.api.entity.dto.EmailNormalDTO;
import top.lixunda.ecommerce.server.auth.api.constants.TemplateEmailIds;
import top.lixunda.commerce.common.core.config.FeignConfig;
import top.lixunda.commerce.common.core.constants.ServiceIds;
import top.lixunda.commerce.common.core.entity.MessageObject;
import top.lixunda.common.validate.XumValid;

import java.util.List;

/**
 * 邮件验证码发送服务
 *
 * @author Xumda
 * @version time:2019/11/22 16:48
 */
@Api("邮件验证码发送服务")
@FeignClient(value = ServiceIds.AUTH_SERVER, configuration = FeignConfig.class)
@RequestMapping("/feign/auth/code/email")
public interface IFeignEmailAuthCode {

    /**
     * 发送自定义信息
     *
     * @param emailNormalDTO EmailNormalDTO
     * @return CacheAuthCode
     */
    @ApiOperation("发送自定义信息")
    @PostMapping("sendMessage")
    MessageObject<Boolean> sendMessage(@RequestBody @XumValid EmailNormalDTO emailNormalDTO);

    /**
     * 发送自定义信息，批量
     *
     * @param list EmailNormalDTO信息，批量
     * @return CacheAuthCode
     */
    @ApiOperation("发送自定义信息，批量")
    @PostMapping("sendMessageList")
    MessageObject<Boolean> sendMessageList(@RequestBody List<EmailNormalDTO> list);

    /**
     * 发送通用验证码消息
     * 模板名称 KEY_GENERAL
     *
     * @param emailGeneralCodeDTO 邮箱验证码通用DTO
     * @return 保存发送的验证码信息DTO
     * @see TemplateEmailIds#KEY_GENERAL_CODE
     */
    @ApiOperation(value = "发送通用验证码消息", notes = "模板名称 KEY_GENERAL")
    @PostMapping("sendGeneralCodeMessage")
    CacheAuthCode sendGeneralCodeMessage(@RequestBody @XumValid EmailGeneralCodeDTO emailGeneralCodeDTO);
}
